﻿IF EXISTS (SELECT * FROM sysobjects WHERE type = 'FN' AND name = 'ufn_UPDMS_Get_Exist_Attach_File_Image')
	BEGIN
		DROP Function ufn_UPDMS_Get_Exist_Attach_File_Image
	END
GO

SET ANSI_NULLS ON
SET QUOTED_IDENTIFIER ON
GO
/******************************************************************************
**	Name : ufn_UPDMS_Get_Exist_Attach_File_Image
**	Desc : 첨부파일에 이미지파일이 있는지 여부
**	Test Exec Query : select dbo.ufn_UPDMS_Get_Exist_Attach_File_Image (111, 'Ref1012m')
**	Called by : Anywhere
**	Program ID : Com3014p
**	Auth : 송시명
**	Date : 2013-06-17
*******************************************************************************
**	Change History
*******************************************************************************
**	Date:		Author:		Description:
**	--------	--------	---------------------------------------
**	
*******************************************************************************/
CREATE FUNCTION [dbo].[ufn_UPDMS_Get_Exist_Attach_File_Image]
(
@ls_activity_id int,
@ls_activity_cd nvarchar(10)
)
RETURNS varchar(1)
AS

BEGIN
    DECLARE @rtn varchar(1)
    SET @rtn = ''

    SELECT @rtn = COUNT(*)
      FROM UPDMS_COM_FILE WITH(NOLOCK)
     WHERE Activity_Id = @ls_activity_id
       AND Activity_Cd = @ls_activity_cd
       AND UPPER(File_Ext) IN ('GIF','JPG','JPEG','PNG','BMP','TIF')

    RETURN LTRIM(RTRIM(@rtn))
END